@ECHO off
IF EXIST "%programfiles%\TortoiseSVN\" goto TORTFOLDEREXIST
echo wscript.quit MsgBox ("TortoiseSVN doesn't seem to be installed, would you like to download it?", 4, "Please choose") > yesno.vbs
wscript //nologo yesno.vbs
set value=%errorlevel%
del yesno.vbs
if "%value%"=="6" goto CEB
if "%value%"=="7" Goto CEA                                                                
:CEA
msg * This script can't be used without tortoisesvn.
cls
goto CFinish
:TORTFOLDEREXIST

IF EXIST "%programfiles%\TortoiseSVN\bin\svn.exe" goto TorToiseSVNFinish
msg * "The commandline tool of TortoiseSVN isn't installed. please reinstall with the commandline enabled. WARNING COMMANDLINE ISN'T ENABLED BY DEFAULT"    
cls
goto CFinish                                                           
:CEB
IF EXIST %programfiles(x86)% goto CEB32
goto CEB64
:CEB32
bitsadmin.exe /Transfer TortoiseSVN http://software-files-a.cnet.com/s/software/12/77/34/21/TortoiseSVN-1.7.10.23359-win32-svn-1.7.7.msi "%~dp0TortoiseSVNSetup.msi"
cls
msg * Please install tortoiseSVN Manualy
goto CFinish
:CEB64
set help=%~dp0
bitsadmin /Transfer TortoiseSVN http://software-files-a.cnet.com/s/software/12/77/34/28/TortoiseSVN-1.7.10.23359-x64-svn-1.7.7.msi "%help%TortoiseSVNSetup.msi"
cls
msg * Please install TortoiseSVN Manualy
goto CFinish
:TorToiseSVNFinish
if exist "%programfiles(x86)%\Microsoft Visual Studio 9.0" goto start
if exist "%programfiles%\Microsoft Visual Studio 9.0" goto start
echo wscript.quit MsgBox ("Microsoft Visual C++ 2008 doesn't seem to be installed, would you like to download it?", 4, "Please choose") > yesno.vbs
wscript //nologo yesno.vbs
set value=%errorlevel%
del yesno.vbs
if "%value%"=="6" goto MVC+
if "%value%"=="7" Goto CFinish                                                                
:MVC+
bitsadmin.exe /Transfer MVC http://download.microsoft.com/download/d/c/3/dc3439e7-5533-4f4c-9ba0-8577685b6e7e/vbsetup.exe "%~dp0VISUALsetup.msi"
cls
msg * Please install Microsoft Visual C++ Manualy
goto CFinish
:start
IF NOT EXIST "%programfiles(x86)%" goto 32BIT-SCRIPT

set tortoisesvncmd="%ProgramFiles%\TortoiseSVN\bin\svn.exe"
set visualexpress2008cmd="%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\VC\vcpackages\vcbuild.exe"
echo ___                      _                _  _                                        
echo !   \  ___ __ __ __ _ _  ! ! ___  __ _  __! !(_) _ _   __ _   
echo ! !) !/ _ \\ V  V /! ' \ ! !/ _ \/ _` !/ _` !! !! ' \ / _` ! 
echo !___/ \___/ \_/\_/ !_!!_!!_!\___/\__,_!\__,_!!_!!_!!_!\__, ! 
echo ___ ___  _  _  _ _  __  ___                            !___/     
echo (_--/ _ \! !! !! '_!/ _!/ -_)
echo /__/\___/ \_,_!!_!  \__!\___!     
echo. 
echo.
echo Downloading Source                                                                                                  
timeout /t 3 >nul
%tortoisesvncmd% checkout http://mc-server.googlecode.com/svn/trunk/
cd trunk
cd VC2008
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo   ___                    _  _  _             
echo  / __! ___  _ __   _ __ (_)! !(_) _ _   __ _ 
echo ! (__ / _ \! '  \ ! '_ \! !! !! !! ' \ / _` !
echo  \___!\___/!_!_!_!! .__/!_!!_!!_!!_!!_!\__, !
echo                   !_!                  !___/ 
echo.
echo.
echo.
echo.
echo.
echo.
echo.
timeout /t 3 >nul
%visualexpress2008cmd% /build MCServer.sln "Release|Win32"
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo _______ _________ _       _________ _______           _______  ______  
echo (  ____ \\__   __/( (    /!\__   __/(  ____ \!\     /!(  ____ \(  __  \ 
echo ! (    \/   ) (   !  \  ( !   ) (   ! (    \/! )   ( !! (    \/! (  \  )
echo ! (__       ! !   !   \ ! !   ! !   ! (_____ ! (___) !! (__    ! !   ) !
echo !  __)      ! !   ! (\ \) !   ! !   (_____  )!  ___  !!  __)   ! !   ! !
echo ! (         ! !   ! ! \   !   ! !         ) !! (   ) !! (      ! !   ) !
echo ! )      ___) (___! )  \  !___) (___/\____) !! )   ( !! (____/\! (__/  )
echo !_!       \_______/!/    )_)\_______/\_______)!/     \!(_______/(______/ 
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
:Configuration
echo wscript.quit MsgBox ("Would you like to configurate MC-Server?", 4, "Please choose") > yesno.vbs
wscript //nologo yesno.vbs
set value=%errorlevel%
del yesno.vbs
if "%value%"=="6" goto A
if "%value%"=="7" Goto B                                                                  
:A
cls
echo Alright we start with your username.
echo. 
cd ..
cd MCServer
set /p Admin=Please Enter your Username: 

cls
del users.ini
Echo [%Admin%]>> users.ini
Echo Groups=Admins>> users.ini

echo wscript.quit MsgBox ("Would you like to have more people with admin permissions?", 4, "Please choose") > yesno.vbs
wscript //nologo yesno.vbs
set value=%errorlevel%
del yesno.vbs
if "%value%"=="6" goto MNY
if "%value%"=="7" Goto MNN                                                                
:MNY
set /p Nickname=Please Enter Another Username: 

cls
Echo.>> users.ini
Echo [%Nickname%]>> users.ini
Echo Groups=Admins>> users.ini
echo wscript.quit MsgBox ("Would you like to have more people with admin permissions?", 4, "Please choose") > yesno.vbs
wscript //nologo yesno.vbs
set value=%errorlevel%
del yesno.vbs
if "%value%"=="6" goto MNY
if "%value%"=="7" Goto MNN                                                                

:MNN
set /p Port=Please Enter your server port (default minecraft is 25565): 

cls
set /p MaxPlayers= Please enter the maxplayers able to join: 

cls
set /p Description=Please enter your server description: 

cls
del settings.ini
echo [Server]>> settings.ini
echo Port=%port%>> settings.ini
echo MaxPlayers=%MaxPlayers%>> settings.ini
echo Description=%Description%>> settings.ini

set /p Worldname=Please set your Default Worldname WARNING DON'T USE SPACES: 

cls

echo.>> settings.ini
echo [Worlds]>> settings.ini
echo DefaultWorld=%Worldname%>> settings.ini
:World
echo wscript.quit MsgBox ("Would you like to have more worlds?", 4, "Please choose") > yesno.vbs
wscript //nologo yesno.vbs
set value=%errorlevel%
del yesno.vbs
if "%value%"=="6" goto CWY
if "%value%"=="7" Goto CWN                                                                
:CWY

set /p World=Please choose another worldname: 
cls
set World=%World: =%
echo World=%World%>> settings.ini
goto World
:CWN
echo wscript.quit MsgBox ("Would you like to have the Core plugin working?", 4, "Please choose") > yesno.vbs
wscript //nologo yesno.vbs
set value=%errorlevel%
del yesno.vbs
if "%value%"=="6" goto Y
if "%value%"=="7" Goto N                                                                

:Y
cls
echo.>> settings.ini
echo [Plugins]>> settings.ini
echo Plugin=Core>> settings.ini

echo wscript.quit MsgBox ("Would you like to have the /pluginlist command work?", 4, "Please choose") > yesno.vbs
wscript //nologo yesno.vbs
set value=%errorlevel%
del yesno.vbs
if "%value%"=="6" goto PLY
if "%value%"=="7" Goto N                                                              

:PLY
echo.>> settings.ini
echo [HelpPlugin]>> settings.ini
echo ShowPluginNames=1 >> settings.ini

goto Next

:N
echo.>> settings.ini
echo [Plugins]>> settings.ini
echo.>> settings.ini
echo [HelpPlugin]>> settings.ini
echo ShowPluginNames=0 >> settings.ini

:Next

echo wscript.quit MsgBox ("Would you like to have mobs enabled?", 4, "Please choose") > yesno.vbs
wscript //nologo yesno.vbs
set value=%errorlevel%
del yesno.vbs
if "%value%"=="6" goto Yes
if "%value%"=="7" Goto No                                                              

:Yes
echo.>> settings.ini
echo [Monsters]>> settings.ini
echo AnimalsOn=1 >> settings.ini
echo AnimalSpawnInterval=10 >> settings.ini
echo Types=Spider,Chicken,Cow,Pig,Sheep,Squid,Enderman,Zombiepigman,Cavespider,Creeper,Ghast,Silverfish,Skeleton,Slime,Spider,Zombie>> settings.ini

Goto Next2

:No
echo.>> settings.ini
echo [Monsters]>> settings.ini
echo AnimalsOn=0 >> settings.ini
echo AnimalSpawnInterval=10 >> settings.ini
echo Types=Spider,Chicken,Cow,Pig,Sheep,Squid,Enderman,Zombiepigman,Cavespider,Creeper,Ghast,Silverfish,Skeleton,Slime,Spider,Zombie>> settings.ini

:Next2
echo wscript.quit MsgBox ("Would you like to have authentication on?", 4, "Please choose") > yesno.vbs
wscript //nologo yesno.vbs
set value=%errorlevel%
del yesno.vbs
if "%value%"=="6" goto Yy
if "%value%"=="7" Goto Nn                                                                

:Yy
echo. >> settings.ini
echo [Authentication]>> settings.ini
echo Server=session.minecraft.net>> settings.ini
echo Address=/game/checkserver.jsp?user=%%USERNAME%%^&serverId=%%SERVERID%%>> settings.ini
echo Authenticate=1 >> settings.ini
goto next3

:Nn
echo.>> settings.ini
echo [Authentication]>> settings.ini
echo Server=session.minecraft.net>> settings.ini
echo Address=/game/checkserver.jsp?user=%%USERNAME%%^&serverId=%%SERVERID%%>> settings.ini
echo Authenticate=0 >> settings.ini

:next3
cls
echo.
echo.
echo.
echo   ___           __ _                    _   _          
echo  / __!___ _ _  / _(_)__ _ _  _ _ _ __ _! !_(_)___ _ _  
echo ! (__/ _ \ ' \!  _! / _` ! !! ! '_/ _` !  _! / _ \ ' \ 
echo  \___\___/_!!_!_! !_\__, !\_,_!_! \__,_!\__!_\___/_!!_!
echo                     !___/           
echo  ___ _      _    _           _ 
echo ! __(_)_ _ (_)__! !_  ___ __! !
echo ! _!! ! ' \! (_-- ' \/ -_) _` !
echo !_! !_!_!!_!_/__/_!!_\___\__,_!
echo.
echo.
echo.
echo configuration finished                                                  
timeout /t 3 >nul
Goto Finish

:B
cls
cd ..
cd MCServer
Echo Thank you for Downloading MC-Server
Timeout /t 3 >nul


:Finish
cd ..
cd..
mkdir MCServer
cd MCServer
mkdir Plugins
cd Plugins
mkdir Core
cd ..
mkdir webadmin
cd ..
xcopy /Q /Y trunk\MCServer MCServer
cls
xcopy /Q /Y trunk\MCServer\Plugins MCServer\plugins
cls
xcopy /Q /Y trunk\MCServer\Plugins\core MCServer\plugins\core
cls
xcopy /Q /Y trunk\MCServer\webadmin MCServer\webadmin
cls
cd MCServer
del MCServer.pdb
cd ..
svn info http://mc-server.googlecode.com/svn/trunk/ | find "Revision" >> revision.txt

set /p texte=< Revision.txt  
msg * you checked out %texte%
msg * Thank you for downloading MC-Server.
goto ffinish


:32BIT-SCRIPT
set tortoisesvncmd="%ProgramFiles%\TortoiseSVN\bin\svn.exe"
set visualexpress2008cmd="%ProgramFiles%\Microsoft Visual Studio 9.0\VC\vcpackages\vcbuild.exe"
echo ___                      _                _  _                                        
echo !   \  ___ __ __ __ _ _  ! ! ___  __ _  __! !(_) _ _   __ _   
echo ! !) !/ _ \\ V  V /! ' \ ! !/ _ \/ _` !/ _` !! !! ' \ / _` ! 
echo !___/ \___/ \_/\_/ !_!!_!!_!\___/\__,_!\__,_!!_!!_!!_!\__, ! 
echo ___ ___  _  _  _ _  __  ___                            !___/     
echo (_--/ _ \! !! !! '_!/ _!/ -_)
echo /__/\___/ \_,_!!_!  \__!\___!     
echo. 
echo.
echo Downloading Source                                                                                                  
timeout /t 3 >nul
%tortoisesvncmd% checkout http://mc-server.googlecode.com/svn/trunk/
cd trunk
cd VC2008
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo   ___                    _  _  _             
echo  / __! ___  _ __   _ __ (_)! !(_) _ _   __ _ 
echo ! (__ / _ \! '  \ ! '_ \! !! !! !! ' \ / _` !
echo  \___!\___/!_!_!_!! .__/!_!!_!!_!!_!!_!\__, !
echo                   !_!                  !___/ 
echo.
echo.
echo.
echo.
echo.
echo.
timeout /t 3 >nul
%visualexpress2008cmd% /rebuild MCServer.sln "Release|Win32"
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo _______ _________ _       _________ _______           _______  ______  
echo (  ____ \\__   __/( (    /!\__   __/(  ____ \!\     /!(  ____ \(  __  \ 
echo ! (    \/   ) (   !  \  ( !   ) (   ! (    \/! )   ( !! (    \/! (  \  )
echo ! (__       ! !   !   \ ! !   ! !   ! (_____ ! (___) !! (__    ! !   ) !
echo !  __)      ! !   ! (\ \) !   ! !   (_____  )!  ___  !!  __)   ! !   ! !
echo ! (         ! !   ! ! \   !   ! !         ) !! (   ) !! (      ! !   ) !
echo ! )      ___) (___! )  \  !___) (___/\____) !! )   ( !! (____/\! (__/  )
echo !_!       \_______/!/    )_)\_______/\_______)!/     \!(_______/(______/ 
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
echo !                                                                      !
goto Configuration
:ffinish
